<?php

namespace App\Models\Application;

use Eloquent as Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * Class payableMonthSettlements
 * @package App\Models\Inventory
 * @version April 10, 2017, 11:51 am UTC
 */
class LayoutArea extends Model
{
    use SoftDeletes;

    public $table = 'layout_areas';

    protected $dates = ['deleted_at'];

    public $fillable = [
        // 区位名称
        'name',
        // layoutID
        'layout_id',
        // 数据类型
        'data_type',
        // 录入设备数量
        'data_id',

    ];

    /**
     * Validation rules
     *
     * @var array
     */
    public static $rules = [
        'layout_id' => 'required',
    ];

    /**
     * The attributes that should be casted to native types.
     *
     * @var array
     */
    protected $casts = [
        'layout_name' => 'string',
        'layout_id'   => 'integer',
        'data_type'   => 'integer',
        'data_id'     => 'integer',
    ];

    /**
     * 【关联布局】
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function layout()
    {
        return $this->hasOne(App\Models\Application\Layout::class, 'id', 'layout_id');
    }

}
